// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

const db = cloud.database()
// 云函数入口函数
exports.main =  (event, context) => {
  return new Promise((resolve, reject) => {
    var filter = event.filter ? event.filter : {} ;  //筛选条件，默认为空，格式 {key:'values'}  
    resolve(db.collection(event.name).where(filter).get())  //查询数据并返回给前端  
  })
  
}
